import * as z from "zod";

const CompanyAccountSchema = z.object({
    companyId: z.string().optional(),
    loginName: z.string()
    .min(6, { message: "登录名长度应该在6~12位之间" })
    .max(12, { message: "登录名长度应该在6~12位之间" }),
    nickName: z.string()
    .min(2, { message: "昵称长度应该在2~5位之间" })
    .max(12, { message: "昵称长度应该在2~5位之间" }),
    password: z.string()
    .min(6, { message: "密码长度应为6~12位" })
    .max(12, { message: "密码长度应为6~12位" }),
    confirmPassword: z.string(),
    email: z.string().email({ message: "邮箱格式不正确" }).optional(),
    phone: z.string().min(11, { message: "手机号码格式不正确" }).max(11, { message: "手机号码格式不正确" }).optional(),
    status: z.boolean(),
}).refine(data => data.password === data.confirmPassword, {
    message: "两次密码不一致",
    path: ["confirmPassword"]
});

const CompanyAccountUpdateSchema = z.object({
    userId: z.number(),
    loginName: z.string()
    .min(6, { message: "登录名长度应该在6~12位之间" })
    .max(12, { message: "登录名长度应该在6~12位之间" }),
    nickName: z.string()
    .min(2, { message: "昵称长度应该在2~5位之间" })
    .max(12, { message: "昵称长度应该在2~5位之间" }),
    email: z.string().email({ message: "邮箱格式不正确" }).optional(),
    phone: z.string().min(11, { message: "手机号码格式不正确" }).max(11, { message: "手机号码格式不正确" }).optional(),
    status: z.boolean(),
});

const CompanyAccount = {
    loginName: "",
    password: "",
    email: "",
    phone: "",
    nickName: "",
    roleType: 2,
    status: false
}

const CompanyAccountModel ={
    CompanyAccountSchema,
    CompanyAccountUpdateSchema,
    CompanyAccount
}

export default CompanyAccountModel;